package cn.edu.njupt.post.config;

import cn.edu.njupt.post.interceptor.LoginRequiredInterceptor;
import cn.edu.njupt.post.interceptor.PassportInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    PassportInterceptor passportInterceptor;

    @Autowired
    LoginRequiredInterceptor loginRequiredInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(passportInterceptor);
        registry.addInterceptor(loginRequiredInterceptor).addPathPatterns("/comment/*", "/pullfeeds", "/follow/*", "/unfollow/*", "/like", "/dislike", "/msg","/msg/*", "/post/add");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}

